#include "railroad_operators.hpp"
#include "locomotives.hpp"
#include "railroad_car.hpp"
#include <cassert>
Track *OperatorAssets::createTrack(fp_type length, fp_type speedLimit) {
    const unsigned long currentSize = this->tracks.size();
    Track *createdTrack = new Track(currentSize, length, speedLimit);
    this->tracks.push_back(createdTrack);
    return createdTrack;
}
// 创建一个机车
Locomotive *OperatorAssets::createLocomotive(std::string locoClass,
                                             std::string locoName) {
    const unsigned long currentSize = this->locomotives.size();

    LocomotiveProperty *props =
        this->techSpecificationLibrary->getLocomotiveProperty(locoClass);
    if (props == nullptr) {
        std::cout << "createLocomotive: unknown locomotive class" << locoClass
                  << std::endl;
        assert(false);
        return nullptr;
    }
    if (props->type == LOCOMOTIVE_TYPE_ELECTRIC) {
        ElectricLocomotive *createdLocomotive =
            new ElectricLocomotive(currentSize, locoName, props);

        this->locomotives.push_back(createdLocomotive);
        return createdLocomotive;
    } else {
        std::cout << "createLocomotive: not implemented locomotive type"
                  << props->type << std::endl;
        assert(false);
        return nullptr;
    }
}
// 创建一个车厢

RailroadWagon *OperatorAssets::createWagon(std::string wagonClass,
                                           std::string wagonName) {
    RailroadCarProperty *props =
        this->techSpecificationLibrary->getRailroadCarProperty(wagonClass);
    if (props == nullptr) {
        std::cout << "unknown wagon class" << wagonClass << std::endl;
        assert(false);
        return nullptr;
    }
    return new RailroadWagon(props);
}